import React from 'react';
import { PageHeaderWrapper } from '@ant-design/pro-layout';
import { Card, Switch, Tabs, Form, Input, Button, Select, Checkbox, Row, Col, InputNumber } from 'antd';

const { TabPane } = Tabs;
class ViewSysConfig extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            loading: false,
            visible: false,
            checked: false,
            checkedSoMsg: false,
            checkedRcvMsg: false,
            dataSource: []
        }
    }
    formRef = React.createRef();
    onFinish = (values) => {
        console.log(values)
    }
    render() {
        const layout = {
            labelCol: { span: 5 },
            wrapperCol: { span: 19 },
        };
        return (
            <PageHeaderWrapper title={false}>
                <Form {...layout} ref={this.formRef} onFinish={this.onFinish} >
                    <p>
                        <Button type="primary" htmlType="submit">保存</Button>
                    </p>
                    <Card>
                        <Tabs defaultActiveKey="1" >
                            <TabPane tab="全局配置" key="1">
                                <Row gutter={[16, 16]}>
                                    <Col span={12}>
                                        <Form.Item name={['company', 'companyName']} label="公司名称"
                                            rules={[{ required: true, message: "公司名称必填" }]}>
                                            <Input style={{ width: 200 }} />
                                        </Form.Item>
                                        <Form.Item name={['company', 'address']} label="地址">
                                            <Input />
                                        </Form.Item>
                                        <Form.Item name={['company', 'telphone']} label="电话">
                                            <Input style={{ width: 200 }} />
                                        </Form.Item>
                                        <Form.Item name={['company', 'email']} label="邮箱">
                                            <Input style={{ width: 200 }} />
                                        </Form.Item>
                                        <Form.Item name={['company', 'fax']} label="传真">
                                            <Input style={{ width: 200 }} />
                                        </Form.Item>
                                    </Col>

                                </Row>
                            </TabPane>
                            <TabPane tab="财务设置" key="2">
                                <Row>
                                    <Col span={12}>
                                        <Form.Item name={['company', 'CostMethod']} label="成本核算方法">
                                            <Select style={{ width: 200 }} placeholder="核算方法">
                                                <Select.Option key="Average">平均</Select.Option>
                                                <Select.Option key="First">先进先出</Select.Option>
                                                <Select.Option key="Last">最后</Select.Option>
                                                <Select.Option key="Standard">标准</Select.Option>
                                            </Select>
                                        </Form.Item>
                                        <Form.Item name={['company', 'BaseCurrCode']} label="本币设置">
                                            <Select style={{ width: 200 }} placeholder="请选择币种">
                                                <Select.Option key="CNY">人民币</Select.Option>
                                                <Select.Option key="USD">美元</Select.Option>
                                            </Select>
                                        </Form.Item>
                                        <Form.Item name={['company', 'TaxRegionCode']} label="应纳税">
                                            <Input suffix="%" style={{ width: 200 }} />
                                        </Form.Item>
                                        <Form.Item name={['company', 'DecimalsCost']} label="成本精度">
                                            <InputNumber min={0} max={18} />
                                        </Form.Item>
                                        <Form.Item name={['company', 'DecimalsPrice']} label="价格精度">
                                            <InputNumber min={0} max={18} />
                                        </Form.Item>
                                        <Form.Item name={['company', 'DecimalsGeneral']} label="一般精度">
                                            <InputNumber min={0} max={18} />
                                        </Form.Item>
                                    </Col>
                                </Row>
                            </TabPane>
                            <TabPane tab="生产设置" key="3">
                                <Tabs defaultActiveKey="S1" >
                                    <TabPane tab="销售" key="S1">
                                        <Row>
                                            <Col span={12}>
                                                <Form.Item name={['company', 'StartOrderNum']} label="起始订单号">
                                                    <Input style={{ width: 200 }} />
                                                </Form.Item>
                                                <Form.Item name={['company', 'EnableRcvMsg']} label="启用订单消息">
                                                    <Checkbox onChange={(e) => { this.setState({ checkedSoMsg: e.target.checked }); }} />
                                                </Form.Item>
                                                <Form.Item name={['company', 'SoMsgTemplate']} label="订单消息模板">
                                                    <Input disabled={!this.state.checkedSoMsg} />
                                                </Form.Item>
                                            </Col>
                                        </Row>
                                    </TabPane>
                                    <TabPane tab="工单" key="S2">
                                        <Row>
                                            <Col span={12}>
                                                <Form.Item name={['company', 'JobSeqLength']} label="工单编号长度">
                                                    <InputNumber min={0} max={18} />
                                                </Form.Item>
                                                <Form.Item name={['company', 'NextJobNumber']} label="下一个工单号">
                                                    <Input style={{ width: 200 }} />
                                                </Form.Item>
                                            </Col>
                                            <Col span={12}></Col>
                                        </Row>
                                    </TabPane>
                                    <TabPane tab="质量" key="S3">
                                        <Row>
                                            <Col span={12}>
                                                <Form.Item label="默认检验仓库" style={{ marginBottom: 0 }}>
                                                    <Input.Group compact>
                                                        <Form.Item name={['company', 'DefInspWhse']}>
                                                            <Select style={{ width: 200 }} placeholder="仓库">
                                                            </Select>
                                                        </Form.Item>
                                                        <Form.Item name={['company', 'DefInspBin']}>
                                                            <Input placeholder="库位" />
                                                        </Form.Item>
                                                    </Input.Group>
                                                </Form.Item>
                                            </Col>
                                        </Row>
                                    </TabPane>
                                    <TabPane tab="仓库" key="S4">
                                        <Row>
                                            <Col span={12}>
                                                <Form.Item label="默认仓库" style={{ marginBottom: 0 }}>
                                                    <Input.Group compact>
                                                        <Form.Item name={['company', 'DefaultWhse']}>
                                                            <Select style={{ width: 200 }} placeholder="仓库">
                                                            </Select>
                                                        </Form.Item>
                                                        <Form.Item name={['company', 'DefaultBin']}>
                                                            <Input placeholder="库位" />
                                                        </Form.Item>
                                                    </Input.Group>
                                                </Form.Item>
                                                <Form.Item label="默认收货仓库" style={{ marginBottom: 0 }}>
                                                    <Input.Group compact>
                                                        <Form.Item name={['company', 'DefRcvWhse']}>
                                                            <Select style={{ width: 200 }} placeholder="仓库">
                                                            </Select>
                                                        </Form.Item>
                                                        <Form.Item name={['company', 'DefaultRcvBin']}>
                                                            <Input placeholder="库位" />
                                                        </Form.Item>
                                                    </Input.Group>
                                                </Form.Item>
                                                <Form.Item label="默认出货仓库" style={{ marginBottom: 0 }}>
                                                    <Input.Group compact>
                                                        <Form.Item name={['company', 'DefShipWhse']}>
                                                            <Select style={{ width: 200 }} placeholder="仓库">
                                                            </Select>
                                                        </Form.Item>
                                                        <Form.Item name={['company', 'DefShipBin']}>
                                                            <Input placeholder="库位" />
                                                        </Form.Item>
                                                    </Input.Group>
                                                </Form.Item>
                                            </Col>
                                            <Col span={12}>
                                                <Form.Item name={['company', 'EnableRcvMsg']} label="启用到货提醒">
                                                    <Checkbox onChange={(e) => { this.setState({ checkedRcvMsg: e.target.checked }); }} />
                                                </Form.Item>
                                                <Form.Item name={['company', 'RcvMsgTemplate']} label="到货提醒模板">
                                                    <Input disabled={!this.state.checkedRcvMsg} />
                                                </Form.Item>
                                            </Col>
                                        </Row>
                                    </TabPane>
                                    <TabPane tab="采购" key="S5">
                                        <Row>
                                            <Col span={12}>
                                                <Form.Item name={['company', 'StartPONum']} label="起始PO号">
                                                    <Input style={{ width: 200 }} />
                                                </Form.Item>
                                                <Form.Item name={['company', 'EnableSugg']} label="启用采购建议">
                                                    <Checkbox onChange={(e) => { this.setState({ checked: e.target.checked }); }} />
                                                </Form.Item>
                                                <Form.Item name={['company', 'SuggMsgTemplate']} label="采购建议模板">
                                                    <Input disabled={!this.state.checked} />
                                                </Form.Item>
                                            </Col>
                                        </Row>
                                    </TabPane>
                                </Tabs>
                            </TabPane>
                        </Tabs>
                    </Card>
                </Form>
            </PageHeaderWrapper>
        )
    }
}
export default ViewSysConfig;